package com.testing.class7;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Classname ExcelWriterTest
 * @Description 类型说明
 * @Date 2022/10/19 19:44
 * @Created by 特斯汀Roy
 */
public class ExcelWriterTest {
    public static void main(String[] args) throws IOException, InvalidFormatException {
        File file =new File("D:\\test.xlsx");
        file.createNewFile();
        XSSFWorkbook workbook=new XSSFWorkbook();
        XSSFSheet testsheet = workbook.createSheet("测试sheet页");
        XSSFRow row = testsheet.createRow(0);
        XSSFCell cell = row.createCell(0);
        cell.setCellValue("test");
        FileOutputStream out=new FileOutputStream(file);
        workbook.write(out);
        workbook.close();
        out.close();

    }
}
